import 'package:flutter/material.dart';
import 'package:flutter_cwhisky/common/style/images.dart';

import '../image/flutter_gifimage.dart';

class LoadingWidget extends StatefulWidget {
  const LoadingWidget({Key? key}) : super(key: key);

  @override
  _LoadingWidgetState createState() {
    return _LoadingWidgetState();
  }
}

class _LoadingWidgetState extends State<LoadingWidget> with TickerProviderStateMixin {
  late GifController _gifController;

  @override
  void initState() {
    _gifController = GifController(vsync: this);

    WidgetsBinding.instance.addPostFrameCallback((_) {
      // Future.delayed(const Duration(milliseconds: 50), () {
        _gifController.repeat(min: 0, max: 48, period: const Duration(milliseconds: 1600));
      // });
    });
    super.initState();
  }

  @override
  void dispose() {
    _gifController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return GifImage(image: const AssetImage(AppImages.loadingGif),width: 80,height: 80, controller: _gifController);
  }
}
